<template>
  <el-radio-group v-model="currentValue" @input="onInputSelect">
    <el-radio v-for="item in optionsVar" :key="item.id" :label="item.id">{{ item.codname }}</el-radio>
  </el-radio-group>
</template>
<script>
export default {
  // eslint-disable-next-line vue/require-prop-types
  props: ['multi', 'name', 'label', 'value', 'disabled', 'optionsurl', 'options'],
  data() {
    return {
      currentValue: this.value,
      optionsVar: null
    }
  },
  watch: {
    value() {
      this.currentValue = this.value
    }
  },
  created() {
    this.currentValue = this.value
    if (this.options) {
      this.optionsVar = this.options
    } else {
      this.queryAction()
    }
  },
  methods: {
    onInputSelect(value) {
      this.$emit('input', this.name, value)
    },
    queryAction() {
      this.api[this.optionsurl]({})
        .then(res => {
          this.optionsVar = res
        })
        .finally(() => {
          this.pagelistLoading = false
        })
    }
  }
}
</script>
